package com.hk.huakangcompany.mapper;

import com.hk.huakangcompany.model.Nav;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: zhe
 * @Date: 2021/6/21 14:23
 * @Statement: 导航Mapper层接口
 */
public interface NavMapper extends BaseMapper<Nav> {


    @Results(id = "navMap",
            value = {
                    @Result(id = true, property = "id", column = "id"),
                    @Result(property = "gmtCreate", column = "gmt_create"),
                    @Result(property = "gmtModified", column = "gmt_modified")
            }
    )
    @Select("select * from nav")
    @Override
    List<Nav> findAll(Nav nav);

    @Select("select count(1) from nav")
    @Override
    int count(Nav nav);

    @ResultMap("navMap")
    @Select("select * from nav where id = #{id}")
    @Override
    Nav findById(Integer id);

    @Insert("insert into nav value " +
            " (null,#{name},#{url},#{gmtCreate},#{gmtModified})")
    @Override
    int save(Nav nav);

    @Update("update nav set " +
            "name=#{name},url=#{url},gmt_modified=#{gmtModified} where id = #{id}")
    @Override
    int update(Nav nav);

    @Delete("delete from nav where id = #{id}")
    @Override
    int delete(Integer id);
}
